package net.halflite.mzkr.action.regist;

import javax.annotation.Resource;

import net.halflite.mzkr.form.regist.RegistUserForm;
import net.halflite.mzkr.service.RegistedUserService;

import org.apache.struts.action.ActionMessages;
import org.seasar.struts.annotation.ActionForm;
import org.seasar.struts.annotation.Execute;
import org.seasar.struts.enums.SaveType;

/** 一時登録のアクションクラス */
public class TempAction {

	@Resource
	private RegistedUserService registedUserService;
	
	@ActionForm
	@Resource(name = "regist_registUserForm")
	private RegistUserForm form;

	/** 一時登録情報入力 */
    @Execute(validator = false)
    public String index() {
        return "index.jsp";
    }

    /** 一時登録情報登録 */
    @Execute(validate = "validate", saveErrors = SaveType.SESSION, input = "./?redirect=true")
    public String post() {
    	registedUserService.registTemp(form);
        return "success?redirect=true";
    }

    /** 一時登録完了 */
    @Execute(validator = false, removeActionForm = true)
    public String success() {
        return "success.jsp";
    }
    
    /** ユーザー登録のフォーム検証 */
    public ActionMessages validate() {
    	return registedUserService.validateRegistTemp(form);
    }
}
